/**
 * 
 */
package com.wgo.precise.client.ui.controller;

import com.wgo.precise.client.ui.model.ClientModelItem;
import com.wgo.precise.client.ui.model.facade.IModelPersistable;
import com.wgo.precise.client.ui.view.facade.IExtendedEditorPart;


/**
 * @author petterei
 * @version $Id: EditorWindowManager.java,v 1.1 2006-02-06 09:29:08 petterei Exp $
 */
public interface EditorWindowManager {

	/**
	 * Starts og gives the current editor focus.
	 * 
	 * @param editorIdentifier The editors identifier
	 * @param input The editor input
	 */
	public void startEditorPart(String editorIdentifier, ClientModelItem input);

	/**
	 * Adds an editor to the managers registry.
	 * 
	 * @param editor The editor to be added
	 */
	public void addExtendedEditor(IExtendedEditorPart editor);
	
	/**
	 * Removes an editor from the managers registry.
	 * 
	 * @param editor The editor to be removed.
	 */
	public void removeExtendedEditor(IExtendedEditorPart editor);

	/**
	 * Initializes editors with appropriate content if possible throw an 
	 * exception if not..) close "other" editors. Is typically called after a 
	 * login.
	 * [
	 * 1. iterate over editors with dbid, replace dummies with real concepts
	 * 2. check for registered editors with non-persisted items - log error
	 * 3. close other editors
	 * ]
	 */
	void initEditors() ;
	
	/**
	 * Empties editors with persistable content, other editors are closed.
	 * [
	 * 1. call flush
	 * 2. close nonpersisted editors (log something)
	 * 3. replace editor contents with dummies
	 * 4. close other editors
	 * ]
	 */
	void resetEditors();
	
	/**
	 * Closes an editor (typically when an item is beeing deleted).
	 * 
	 * @param item The corresponding editor to be closed.
	 */
	void closeEditor(IModelPersistable item);

	/**
	 * Closes an editor and all corresponding childrens items editors (typically
	 * when an item is beeing deleted). 
	 * 
	 * @param item
	 */
	void closeEditorHierarchy(IModelPersistable item);

	/**
	 * only to be called after a save (that is, when every item has an 
	 * database-id)
	 * [
	 * 1. iterate  over nonpersisted items editors, move to real editors 
	 *    registry if confitions are met (log error if not)
	 * 2. iterate "other" editors, log error..
	 * ]
	 */
	void flushNonPersistedItemsEditors();
	
	/**
	 * Close all editors, validate that registry is empty, log error if not.
	 */
	void closeEditors();
}
